package com.csht.util.quartz;

import java.util.List;

import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import com.csht.service.CshtGoodsService;
import com.csht.service.CshtTenGoodsEverydayService;

public class TenGoodsQuartz {
	
	@Autowired
	private CshtGoodsService cshtGoodsService;
	
	@Autowired
	private CshtTenGoodsEverydayService cshtTenGoodsEverydayService;

	public void tenGoods() throws JobExecutionException{
		
		System.out.println("-----------每日十件商品更新中-----------");
		try {
			System.out.println("清空CshtTenGoodsEveryday表");
			cshtTenGoodsEverydayService.truncateTable();
			System.out.println("随机获取十条商品id");
			List<Integer> tenGoodsIdList = cshtGoodsService.suiJiGetTenGoodsId();
			System.out.println("更新每日十件表");
			cshtTenGoodsEverydayService.updateTenGoodsEveryday(tenGoodsIdList);
		}catch(Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("-----------每日十件商品更新完成-----------");
	}
	
	
}
